import axios from 'axios';

const request =axios.create({
    baseURL:'http://doulj.cn:7002/',
    timeout:10000
})
//添加请求拦截器
request.interceptors.request.use((config) => {
    // 发送请求之前
    const token = localStorage.getItem('token')
    config.headers.Authorization = `Bearer ${token}`;
    return config
}, function (error) {
    //错误请求
    return Promise.reject(error)
})
//添加响应拦截器
request.interceptors.response.use((res) => {
    // 响应数据
    return res.data
}, function (error) {
    // 响应错误
    return Promise.reject(error)
})
export default request